
/**
 * 编写费率上传的接口
 */
const {dbRate} = require('../../dao/dao-control');
const prCarRateBatch =require("../../controller/rate/pr-car-batch")
const reLifeRateBatch =require("../../controller/rate/re-life-batch")
const reIllnessRateBatch =require("../../controller/rate/re-illness-batch")
const lifeIllnessRateBatch =require("../../controller/rate/life-illness-batch")

module.exports= {
    post: {

        // 私家车意外
        'rate-pr-car':async (ctx, next) => {
            ctx.body = await prCarRateBatch(ctx.request.body);
            next();
        },

        // 定期重疾
        'rate-re-illness':async (ctx, next) => {
            ctx.body = await reIllnessRateBatch(ctx.request.body);
            next();
        },

        // 终身重疾
        'rate-life-illness':async (ctx, next) => {
            ctx.body = await lifeIllnessRateBatch(ctx.request.body);
            next();
        },

        // 定期寿险
        'rate-re-life':async (ctx, next) => {
            ctx.body = await reLifeRateBatch(ctx.request.body);
            next();
        }
    },
    get: {

        // 私家车意外
        'rate-pr-car':async (ctx, next) => {
            let productId = ctx.request.query.id ;
            ctx.body = await dbRate.getPrCar(productId);
            next();
        },

        // 定期重疾
        'rate-re-illness':async (ctx, next) => {
            let productId = ctx.request.query.id ;
            ctx.body = await dbRate.getReIllness(productId);
            next();
        },

        // 终身重疾
        'rate-life-illness':async (ctx, next) => {
            let productId = ctx.request.query.id ;
            ctx.body = await dbRate.getLifeIllness(productId);
            next();
        },

        // 定期寿险
        'rate-re-life':async (ctx, next) => {
            let productId = ctx.request.query.id ;
            ctx.body = await dbRate.getReLife(productId);
            next();
        }
    }
}